#pragma once

inline DWORD BKDRHash(const char* pszStr)
{
	DWORD dwSeed = 131; // 31 131 1313 13131 131313 etc..
	DWORD dwHash = 0;
 
	while (*pszStr)
	{
		dwHash = dwHash * dwSeed + (*pszStr++);
	}
 
	return (dwHash & 0x7FFFFFFF);
}

inline DWORD DJBHash(char* pszStr)
{
	DWORD dwHash = 5381;
 
	while (*pszStr)
	{
		dwHash += (dwHash << 5) + (*pszStr++);
	}
 
	return (dwHash & 0x7FFFFFFF);
}

inline DWORD APHash(const char* pszStr)
{
	DWORD dwHash = 0;
 
	for (int i = 0; *pszStr; i++)
	{
		if ((i & 1) == 0)
		{
			dwHash ^= ((dwHash << 7) ^ (*pszStr++) ^ (dwHash >> 3));
		}
		else
		{
			dwHash ^= (~((dwHash << 11) ^ (*pszStr++) ^ (dwHash >> 5)));
		}
	}
 
	return (dwHash & 0x7FFFFFFF);
}